package com.zenchn.dynamic;

import static com.zenchn.dynamic.TMiRegionDetailDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TMiRegionDetail;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TMiRegionDetailDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    BasicColumn[] selectList = BasicColumn.columnList(id, regionId, areasCode, creator, createTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TMiRegionDetail> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TMiRegionDetail> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TMiRegionDetailResult")
    Optional<TMiRegionDetail> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TMiRegionDetailResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="region_id", property="regionId", jdbcType=JdbcType.CHAR),
        @Result(column="areas_code", property="areasCode", jdbcType=JdbcType.CHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.CHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TMiRegionDetail> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TMiRegionDetail, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TMiRegionDetail, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int deleteByPrimaryKey(String id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int insert(TMiRegionDetail record) {
        return MyBatis3Utils.insert(this::insert, record, TMiRegionDetail, c ->
            c.map(id).toProperty("id")
            .map(regionId).toProperty("regionId")
            .map(areasCode).toProperty("areasCode")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int insertMultiple(Collection<TMiRegionDetail> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TMiRegionDetail, c ->
            c.map(id).toProperty("id")
            .map(regionId).toProperty("regionId")
            .map(areasCode).toProperty("areasCode")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int insertSelective(TMiRegionDetail record) {
        return MyBatis3Utils.insert(this::insert, record, TMiRegionDetail, c ->
            c.map(id).toPropertyWhenPresent("id", record::getId)
            .map(regionId).toPropertyWhenPresent("regionId", record::getRegionId)
            .map(areasCode).toPropertyWhenPresent("areasCode", record::getAreasCode)
            .map(creator).toPropertyWhenPresent("creator", record::getCreator)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default Optional<TMiRegionDetail> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TMiRegionDetail, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default List<TMiRegionDetail> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TMiRegionDetail, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default List<TMiRegionDetail> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TMiRegionDetail, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default Optional<TMiRegionDetail> selectByPrimaryKey(String id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TMiRegionDetail, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    static UpdateDSL<UpdateModel> updateAllColumns(TMiRegionDetail record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(record::getId)
                .set(regionId).equalTo(record::getRegionId)
                .set(areasCode).equalTo(record::getAreasCode)
                .set(creator).equalTo(record::getCreator)
                .set(createTime).equalTo(record::getCreateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TMiRegionDetail record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(record::getId)
                .set(regionId).equalToWhenPresent(record::getRegionId)
                .set(areasCode).equalToWhenPresent(record::getAreasCode)
                .set(creator).equalToWhenPresent(record::getCreator)
                .set(createTime).equalToWhenPresent(record::getCreateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int updateByPrimaryKey(TMiRegionDetail record) {
        return update(c ->
            c.set(regionId).equalTo(record::getRegionId)
            .set(areasCode).equalTo(record::getAreasCode)
            .set(creator).equalTo(record::getCreator)
            .set(createTime).equalTo(record::getCreateTime)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_region_detail")
    default int updateByPrimaryKeySelective(TMiRegionDetail record) {
        return update(c ->
            c.set(regionId).equalToWhenPresent(record::getRegionId)
            .set(areasCode).equalToWhenPresent(record::getAreasCode)
            .set(creator).equalToWhenPresent(record::getCreator)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .where(id, isEqualTo(record::getId))
        );
    }
}